package com.hj.security.utils;

import java.util.List;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;

public class ProcessUtil {

	public static void killAllProcess(Context context){
		//拿到这个包的包管理器
		ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
		//拿到所有正在运行的进程信息 
		List<RunningAppProcessInfo> runningAppProcessInfos = activityManager.getRunningAppProcesses();
		//进行遍历，然后杀死它们
		for (RunningAppProcessInfo runningAppProcessInfo : runningAppProcessInfos) {
			String packageName = runningAppProcessInfo.processName;
			activityManager.killBackgroundProcesses(packageName);
			
		}
	}
}
